package com.cz.kafka.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/send")
@Slf4j
public class SendController {

    @Autowired
    private KafkaTemplate<String, String> template;



    @PostMapping("/message")
    public void send(@RequestBody String message) {
        log.info("send message: " + message);
        template.send("cz", message);
    }
}
